package com.dingding.queue.base.sms.impl;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

import com.dingding.common.core.util.ToolUtil;

import com.dingding.queue.base.sms.AbstractMessageBase;
import com.dingding.queue.base.sms.ISendMessage;
import com.dingding.queue.base.sms.Message;
import com.dingding.queue.base.sms.SendMessageUtil;

/**
 * @Title: MengWangSendMessage.java
 * @Description: 梦网发送短信实现
 * @author ligang
 * @date 2016年12月28日 上午10:19:14
 */
@Component("mengWangSendMessage")
public class MengWangSendMessageImpl extends AbstractMessageBase implements ISendMessage {

	private static final Logger log = Logger.getLogger(MengWangSendMessageImpl.class);
	/**
	 * 
	 * @param telphone
	 *            手机号码
	 * @param msg
	 *            短信内容
	 * @param 参数说明
	 * 
	 * @return boolean true 成功 false 失败
	 * 
	 */
	@Override
	public boolean sendMessage(String telphone, String msg) {

		if (ToolUtil.isBlank(telphone) || ToolUtil.isBlank(msg)) {
			log.error("短信发送出现问题，存在空值!" + "telphone:" + telphone + "msg:" + msg);
			return false;
		}
		Message message = new Message();
		//设置用户账号
		message.setUserid(AbstractMessageBase.userid);
		//设置密码
		message.setPwd(AbstractMessageBase.pwd);
		//设置ip
		message.setIp(AbstractMessageBase.ip);
		//设置端口号
		message.setPort(AbstractMessageBase.port);
		//手机号
		message.setMobile(telphone);
		//短信内容
		message.setContent(msg);
		//是否成功的发送了短信
		boolean flag = SendMessageUtil.sendMengWangSms(message);
		return flag;
	}
}
